#include <iostream>
using namespace std;

int tag[1010];

int main()
{
    int n = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int m = 0;
        cin >> m;
        for (int j = 0; j < m; j++)
        {
            int num = 0;
            cin >> num;
            tag[num]++;
        }
    }
    int Max = 0;
    int t_count = 0;
    for (int i = 0; i <= 1000; i++)
    {
        if (tag[i] >= t_count)
        {
            t_count = tag[i];
            Max = i;
        }
    }
    cout << Max << " " << t_count;
    return 0;
}